package com.imagination.applet.domain.adapter;

import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class OSSConfiguration {
    @Value("${aliyun.oss.endpoint}")
    private String endpoint;
    @Value("${aliyun.oss.access-key-id}")
    private String accessKeyId;
    @Value("${aliyun.oss.access-key-secret}")
    private String accessKeySecret;

    @Bean
    public OSS oss(){
        return new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
    }

    public static String path;

    public static String domainName;

    @Value("${aliyun.oss.root-path}")
    public void setOSSPath(String ossPath) {
        OSSConfiguration.path = ossPath;
    }

    @Value("${resources.static.domain-name}")
    public void setDomainName(String domainName) {
        OSSConfiguration.domainName = domainName;
    }
}
